package Cantella::DJabberd::Web::InterfaceModel::Action::User::Login;

use Reaction::Class;

use Reaction::Types::Core qw/NonEmptySimpleStr Password/;

class Login, is 'Reaction::InterfaceModel::Action', which{
   has username => (is => 'rw',
                    lazy_fail => 1,
                    isa => NonEmptySimpleStr,
                   );
   has password => (is => 'rw',
                    lazy_fail => 1,
                    isa => Password,
                   );

  #XXX make realm an attribute
  implements do_apply => as {
    my $self = shift;
    return $self->ctx->authenticate({
                                     username => $self->username,
                                     password => $self->password
                                    });
  };
};

1;
